package com.jielihaofeng.site.article.convert;

import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class ListToStringTransform {

    public String listToString(List<String> list) {
        return list.stream().collect(Collectors.joining(","));
    }

    public List<String> stringToList(String str) {
        if (StringUtils.isEmpty(str)){
            return new ArrayList<>();
        }
        return Arrays.stream(str.split(",")).collect(Collectors.toList());
    }
}
